package cn.fufeiii.bt.demo.base;

import cn.fufeiii.bt.common.aspect.validation.ModelValidation;
import cn.fufeiii.bt.common.util.result.CommonResult;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * @author FuFei
 */
@Slf4j
@ModelValidation
@RestController
@RequestMapping("/base")
public class BaseController {

    @PostMapping("/out/json")
    public CommonResult<Param> test1(@RequestBody Param param) {
        return CommonResult.success(param);
    }

    @PostMapping("/out/form")
    public CommonResult<Param> test2(Param param) {
        return CommonResult.success(param);
    }

    @GetMapping("/out/url")
    public CommonResult<Param> test3(Param param) {
        return CommonResult.success(param);
    }

    @Data
    public static class Param {
        @Size(min = 10)
        @NotBlank
        private String key;
        private String value;
        private Date d1;
        private LocalDateTime d2;
        private LocalDate d3;
    }

}
